package interview;

import java.util.HashMap;

public class interview_16_02 {
    class WordsFrequency {

        private HashMap<String,Integer> map;
        public WordsFrequency(String[] book) {
            map=new HashMap<>();
            for(String item:book){
                if(map.containsKey(item)){
                    map.put(item,map.get(item)+1);
                }else{
                    map.put(item,1);
                }
            }
        }

        public int get(String word) {
            if(map.containsKey(word)) return map.get(word);
            return 0;
        }
    }
}
